﻿using System;
using System.Collections.Generic;
using Domain.Models;

namespace Web.Logic.Models
{
    public class FilterSet
    {
        public int IdFrom;
        public int IdTo;

        IList<FilterUnit> filterUnits;

        public FilterSet()
        {
            filterUnits = new List<FilterUnit>();
        }

        public IEnumerable<Doer> Filter(IEnumerable<Doer> doers)
        {
            foreach (var filterUnit in filterUnits)
            {
                doers = filterUnit.Filter(doers);
            }
            return doers;
        }

        public void AddFilterUnit(Func<Doer, bool> expr)
        {
            filterUnits.Add(new FilterUnit(expr));
        }
    }
}